public interface InterfaceUSB {

    public abstract void openDevice();
    public abstract void closeDevice();

}

class Mouse implements InterfaceUSB{
    @Override
    public void openDevice() {
        System.out.println("打开鼠标");
    }

    @Override
    public void closeDevice() {
        System.out.println("关闭鼠标");
    }
    public void click() {
        System.out.println("鼠标点击");
    }
}

class KeyBoard implements InterfaceUSB{
    @Override
    public void openDevice() {
        System.out.println("启动键盘");
    }

    @Override
    public void closeDevice() {
        System.out.println("关闭键盘");
    }
    public void knock() {
        System.out.println("敲动键盘");
    }
}
class Computer {
    public void poweron() {
        System.out.println("打开电脑");
    }
    public void powerOff() {
        System.out.println("关闭电脑");
    }

    public void useDevice (InterfaceUSB usb) {
        usb.openDevice();
        if(usb instanceof Mouse) {
            Mouse mouse = (Mouse)usb;
            mouse.click();
        }else if (usb instanceof KeyBoard) {
            KeyBoard keyBoard = (KeyBoard)usb;
            keyBoard.knock();
        }
        usb.closeDevice();
    }

}




